package com.example.demo.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OwnersMapper {
    @Insert("INSERT INTO owners(message_id, tache3_id, tache2_id, tache1_id, car_id,refuse_or_not,wait_time) " +
            "VALUES(#{message_id}, #{tache3_id}, #{tache2_id}, #{tache1_id}, #{car_id}, #{refuse_or_not}, #{wait_time})")
    void setOwners(@Param("message_id") int messageId,
                   @Param("tache3_id") int tache3_id,
                   @Param("tache2_id") int tache2_id,
                   @Param("tache1_id") int tache1_id,
                   @Param("car_id") int carId,
                   @Param("refuse_or_not") int refuse_or_not,
                   @Param("wait_time") int wait_time);
    @Select("select * from owners where message_id = #{message_id}")
    List<Map<String,Object>> getOwnerMatches(@Param("message_id") int message_id);

    @Select("select count(car_id) from owners where message_id = #{message_id}")
    int get_used_car(@Param("message_id") int message_id);

    @Select("select MAX(wait_time) from owners where message_id = #{message_id}")
    int get_wait_time(@Param("message_id") int message_id);
}
